include	config

CPP	= @CXX@
INSTALL_PROGRAM = install

SRCS	= ncolorstring.cpp nhline.cpp nvline.cpp nscrollview.cpp nselectlist.cpp nview.cpp \
          ngroup.cpp nstatictext.cpp nform.cpp nprogram.cpp nmenu.cpp \
          kclog.cpp cfg.cpp srvdata.cpp mbstring.cpp net.cpp resultparse.cpp resultdom.cpp \
          mainprog.cpp infopanel.cpp mainwin.cpp msgwin.cpp taskwin.cpp tui-main.cpp  \
          cfgform.cpp topmenu.cpp about.cpp helpwin.cpp addprojectform.cpp addmgrform.cpp

OBJS	= $(patsubst %.cpp,$(ODIR)/%.o,$(SRCS))
LIBS    = @LIBS@
LDFLAGS = @LDFLAGS@ $(LIBS)
CXXFLAGS = @CXXFLAGS@
ODIR	= .obj
SDIR	= src
exec_prefix = @prefix@
BINDIR = @bindir@
ifeq (@HAVE_OPENSSL@, 1)
    DEFS += -DHAVE_OPENSSL
endif

###############################################################################

all: createobj $(OBJS)
	@echo "\nLinking...\n"
	$(CPP) -o $(TARGET) $(OBJS) $(LDFLAGS)

$(ODIR)/%.o: $(SDIR)/%.cpp
	$(CPP) -c $(CXXFLAGS) $(CPPFLAGS) $(DEFS) -o $(ODIR)/$*.o $<

clean:
	rm -f $(ODIR)/*.o $(TARGET) config.log

install: all
	$(INSTALL_PROGRAM) -d $(DESTDIR)$(BINDIR)
	$(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)$(BINDIR)

createobj:
	@if ! [ -d "$(ODIR)" ] ; then echo "create $(ODIR)";  mkdir $(ODIR); fi

srctgz: clean
	@if ! [ -d "../$(TARGET)-$(VERSION)" ] ; then echo "create symlink ../$(TARGET)-$(VERSION)->$(notdir $(CURDIR))";  ln -n -s $(notdir $(CURDIR)) ../$(TARGET)-$(VERSION); fi
	cd ..; tar --exclude-vcs -vzcf $(TARGET)_$(VERSION).orig.tar.gz \
	$(TARGET)-$(VERSION)/src \
	$(TARGET)-$(VERSION)/redhat \
	$(TARGET)-$(VERSION)/Makefile.in \
	$(TARGET)-$(VERSION)/configure.in \
	$(TARGET)-$(VERSION)/config
